package org.awa.demo.opencv.sound;


/**
 * 相对位置判断
 *
 * @author xxf
 */
public class GisPositionUtil {

    public final static int LEFT_UP = 1;
    public final static int LEFT_DOWN = 2;
    public final static int RIGHT_UP = 3;
    public final static int RIGHT_DOWN = 4;
    public final static int BELOW = 5;
    public final static int ABOVE = 6;

    public static int getPositionRelation(double srcX,double srcY,double distX,double distY){
        double rangeX = distX - srcX;
        double rangeY = distY - srcY;
        if(rangeY > 0){
            //上半部分的左中右
            if(rangeX < -1) {//增加容错，理论上是只要小于0就可判定为左边
                //左边
                return LEFT_UP;
            }else if(rangeX > 1){
                //右边
                return RIGHT_UP;
            }else{
                //正上方
                return ABOVE;
            }
        }else{
            //下半部分的左中右
            if(rangeX < -1) {//增加容错，理论上是只要小于0就可判定为左边
                //左边
                return LEFT_DOWN;
            }else if(rangeX > 1){
                //右边
                return RIGHT_DOWN;
            }else{
                //正下方
                return BELOW;
            }
        }
    }

}
